<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.io.*"  %>
<%@ page import="java.util.*" %>
<%@ page import="java.util.regex.*" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.lang.System" %>
<%@ page import="twitter4j.*" %>
<%@ page import="twitter4j.http.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>타이틀</title>
</head>
<body>
<%
try{
String oAuth = request.getParameter("oauth_token");
//App Key 지정. App을 등록한 후 발급받은 키를 입력
String CONSUMER_KEY = "lLDr77zex3PnPUV5bI9ow";
String CONSUMER_SECRET = "LZQ9bR9MR2eiknDeJsTpfCaCZvQSRnBXRK56D9prx0";
//트위터인스턴스생성
Twitter twitter= new TwitterFactory().getInstance();
twitter.setOAuthConsumer(CONSUMER_KEY,CONSUMER_SECRET);
//Access Token 설정
AccessToken accessToken= null;
accessToken = twitter.getOAuthAccessToken(oAuth, session.getAttribute("reqkey").toString());
twitter.setOAuthAccessToken(accessToken);
//발급받은 키를 세션에 저장
session.setAttribute("acckey",accessToken.getTokenSecret());
session.setAttribute("acc", accessToken.getToken());
%>
<%=session.getAttribute("acckey")%><br>
<%=session.getAttribute("acc")%>
<Script Language="JavaScript">
 location.replace("http://192.168.0.4:8080/TwitterTest/");
</Script>
</body>
</html>
<%
}catch(Exception e) 
{
%>
<Script Language="JavaScript">
 location.replace("에러시 이동 URL");
</Script>
<%
} 
%>